package com.itheima.d4_ExceptionCustom;

public class Test {
    public static void main(String[] args) {
        // 1. 先定义一个异常类
        try {
            checkAge(-4);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void checkAge(int age) {
        if (age < 0 || age > 200){
          // 跑出去
          throw new AgeException(age+"is illegal");
        }else {
            System.out.println("正确");
        }
    }
}

